/**
 * 遥测点相关类型定义
 */

export interface TokenVariant {
  variant_name: string;
  variant_summary?: string;
  variant_summary_zh?: string;
}

export interface TokenInfo {
  token_key: string;
  token_name: string;
  variants?: TokenVariant[];
}

export interface UkmMetricInfo {
  metric_name: string;
  summary?: string;
  deprecated: boolean;
  obsolete_message?: string;
}

export interface TelemetryPoint {
  pointId: string;
  name: string;
  telemetryType: 'UMA' | 'UKM';
  sourceFile: string;
  description?: string;
  teamId?: string;
  teamName?: string;
  analysisStatus: 'NOT_ANALYZED' | 'ANALYZED' | 'NOT_NEEDED' | 'NEEDS_COLLECTION';
  analysisNotes?: string;
  createdAt: string;
  updatedAt: string;
  analyzedBy?: string;
  analyzedAt?: string;
  metadata?: Record<string, any>;
  originalType?: string; // Add original type from backend
  sourceLine?: number;
  chromiumPath?: string;
  descriptionZh?: string; // Add Chinese description field
  ownerEmail?: string;
  units?: string;
  expiresAfter?: string; // Add expiration information
  tokens?: TokenInfo[]; // Add token information
  ownerInChromium?: string; // Add Chromium owner field
  enumValues?: Array<{value: number; label: string; summary?: string; summary_zh?: string}>; // Fix enum values type with Chinese summary
  enum_summary?: string; // Summary of the associated enum (for histograms with enum)
  enum_summary_zh?: string; // Chinese summary of the associated enum (for histograms with enum)
  ukm_metrics?: UkmMetricInfo[]; // Add UKM metrics information
}

/**
 * 目录树节点接口
 */
export interface TreeNode {
  key: string;                          // 唯一标识符
  title: string;                        // 显示名称
  path: string;                         // 完整路径
  isLeaf?: boolean;                     // 是否为叶子节点
  children?: TreeNode[];                // 子节点
  telemetryPoints?: TelemetryPoint[];   // 该节点下的遥测点数据
  stats?: TreeNodeStats;                // 统计信息
  level?: number;                       // 层级深度
  parentKey?: string;                   // 父节点key
}

/**
 * 节点统计信息
 */
export interface TreeNodeStats {
  total: number;                        // 总数
  analyzed: number;                     // 已分析
  notAnalyzed: number;                  // 未分析
  needsCollection: number;              // 需要收集
  notNeeded: number;                    // 不需要分析
  analysisProgress: number;             // 分析进度百分比
}

/**
 * 视图模式类型
 */
export type ViewMode = 'table' | 'tree';

/**
 * 目录树构建器配置
 */
export interface TreeBuilderConfig {
  includeEmptyDirs?: boolean;           // 是否包含空目录
  maxDepth?: number;                    // 最大深度
  sortBy?: 'name' | 'count' | 'status'; // 排序方式
  groupByType?: boolean;                // 是否按类型分组
}

/**
 * 展开的节点状态
 */
export interface ExpandedState {
  keys: string[];                       // 展开的节点keys
  lastUpdated: number;                  // 最后更新时间
}